<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html class="win-frame">
<head>
<title>${name_china}管理-编辑${name_china}</title>
<%@include file="/common/head.jsp" %>

</head>
<body class="iframe-page">
<div class="page-title-wrapper">
    <div class="page-title">
        <div class="page-title-text">
            <span>${name_china}管理</span>
            <span class="split"></span>
            <span>编辑${name_china}</span>
        </div>
        <a id="goBack" class="btn-return distance-left" href="javascript:;"><i class="icon icon-arrow-left"></i>返回上级</a>
    </div>
    <div class="page-title-border"></div>
</div>

<form id="form" method="post">
    <div class="form-wrapper">    
      <input type="hidden" id="id" name="id" value="${id}"/>  
      <div class="form-cont">
          <p class="form-cont-title">推广位ID</p>
          <input type="text" id="tgwId" name="tgwId" class="summer-input summer-validatebox"/>          
       </div>
       <div class="form-cont">
          <p class="form-cont-title">推广位名称</p>
          <input type="text" id="tgwName" name="tgwName" class="summer-input summer-validatebox"/>
       </div>
     <div class="form-btn-wrapper" id="funcbar">
        <a class="btn btn-normal" id="saveBtn">保存</a>
        <a class="btn btn-normal" id="backBtn">关闭</a>
    </div>
  </div>
</form>
<script>
    
  var  permission = CommonUtil.getPermission('${name_english}');
    
    $(function () {
    	//初始化funcbar
     	/* $('#funcbar').prepend($.funcbar({
            type: 'button',
            data: permission,
            permit: ['${name_english}:edit']
        })); */
		//保存按钮
		$('#saveBtn').on('click', submit);
    	//$('#funcbar').on('click', 'a[data-permit="${name_english}:edit"]', submit);

		//返回按钮
		$('#backBtn, #goBack').on('click', backMain);
	});

	//表单提交
	function submit() {
		$("#form").form({
       	 buttons : ['#saveBtn'],
			ajax : {
				url : CONST_URL.EDIT+"?id="+${id},
    			param: {
    				"tgwId": trimSpace($('#tgwId').val()),
    				"tgwName": trimSpace($('#tgwName').val())
            	}
			},
			onSubmitSuccess : function(data) {
				$.stip({
					type : 'ok',//显示类型 有info、 ok、 danger
					text : '保存成功！',
					onBeforeHide : function() {
   	                	if( typeof window.opener == 'object' && typeof window.opener.closeWindow=='function') {
   	                     window.opener.closeWindow(window, true); //不刷新 false
   	                 } 
					}
				});
			}
		}).form("submit");
	}

	//返回主页面
	function backMain() {
		window.location.href = CONST_URL.INIT_MAIN;
	}

	//请求url
	var CONST_URL = {
		INIT_MAIN : basePath + "${common_url}init",
		EDIT : basePath + "${common_url}edit"
	};
</script>
</body>
</html>